using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

namespace OnlineAnadolu
{
    public partial class loginm : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void SubmitButton_Click(object sender, EventArgs e)
        {
            string query = "SELECT contact.email,users.password FROM users INNER JOIN contact ON users.contactid = contact.contactinfoid WHERE (contact.email = N'" + tb_MailAdres.Text + DropDownList1.SelectedItem.Text + "') and issubscribed=1";
            SqlConnection con2 = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["shoppingConnectionString"].ToString());
            SqlCommand cmd2 = new SqlCommand(query, con2);
            SqlDataAdapter ad2 = new SqlDataAdapter(cmd2);
            DataTable dt2 = new DataTable();
            ad2.Fill(dt2);
            foreach (DataRow dr in dt2.Rows)
            {
                Mail m = new Mail();
                m.MailGonder(dr["email"].ToString(), "Sifreniz " + dr["password"].ToString());
                lb_GonderMesaji.Text = "Sifreniz gonderildi.";
            }
            if (dt2.Rows.Count == 0)
                lb_GonderMesaji.Text = "Mailinizi kontrol ediniz";
        }
    }
}
